Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

New Module: docker_network #3728

Closed
wants to merge 1 commit into from
Closed

New Module: docker_network #3728

wants to merge 1 commit into from

Conversation

keitwb
Copy link

@keitwb keitwb commented May 24, 2016

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

docker_network

ANSIBLE VERSION
ansible 2.2.0
  config file = 
  configured module search path = Default w/o overrides
SUMMARY

Implementation of https://github.com/ansible/proposals/blob/master/docker/docker_network.md

{
    "changed": true, 
    "invocation": {
        "module_args": {
            "api_version": null, 
            "cacert_path": null, 
            "cert_path": null, 
            "connected": [
                "ansible-dev", 
                "cm_db_1"
            ], 
            "debug": false, 
            "docker_host": null, 
            "driver": "bridge", 
            "driver_options": {
                "com.docker.network.bridge.name": "test3"
            }, 
            "filter_logger": false, 
            "force": false, 
            "incremental": false, 
            "ipam_driver": null, 
            "ipam_options": {
                "gateway": "172.3.26.1", 
                "iprange": "192.168.1.0/24", 
                "subnet": "172.3.26.0/16"
            }, 
            "key_path": null, 
            "network_name": "ansible-test-3", 
            "ssl_version": null, 
            "state": "present", 
            "timeout": null, 
            "tls": null, 
            "tls_hostname": null, 
            "tls_verify": null
        }
    }, 
    "facts": {
        "Containers": {
            "cee84d31d7f7813c639ff231c297802f45b04e39bb10de36253ffdfae40ad85b": {
                "EndpointID": "8ad46af0d70b92c10cff36dd30b8a6269124980a3318ea5753c8a51cff635c9a", 
                "IPv4Address": "172.3.1.1/16", 
                "IPv6Address": "", 
                "MacAddress": "02:42:ac:03:01:01", 
                "Name": "cm_db_1"
            }, 
            "fe86a4569bd6af468d405050429a1f59712fab019569dd3d1dc42407e432047c": {
                "EndpointID": "5d0eedb1db198ca8ac4c8de4beebc0ffc9c230faa1cb2ec842d7a520912715ef", 
                "IPv4Address": "172.3.1.0/16", 
                "IPv6Address": "", 
                "MacAddress": "02:42:ac:03:01:00", 
                "Name": "ansible-dev"
            }
        }, 
        "Driver": "bridge", 
        "EnableIPv6": false, 
        "IPAM": {
            "Config": [
                {
                    "Gateway": "172.3.26.1", 
                    "IPRange": "192.168.1.0/24", 
                    "Subnet": "172.3.26.0/16"
                }
            ], 
            "Driver": "default", 
            "Options": null
        }, 
        "Id": "277c72ec582c8ac0366734b34605ae5ae6a22b918d720c610d3efd3564c75614", 
        "Internal": false, 
        "Labels": {}, 
        "Name": "ansible-test-3", 
        "Options": {
            "com.docker.network.bridge.name": "test3"
        }, 
        "Scope": "local"
    }
}

@gregdek
Copy link
Contributor

gregdek commented May 24, 2016

Thanks @keitwb for this PR. This PR requires revisions, either because it fails to build or by reviewer request. Please make the suggested revisions. When you are done, please comment with text 'ready_for_review' and we will put this PR back into review.

[This message brought to you by your friendly Ansibull-bot.]

@keitwb keitwb changed the title docker_network Module New Module: docker_network May 24, 2016

def main():
argument_spec = dict(
network_name = dict(type='str', required=True),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs aliases=['name']

@chouseknecht
Copy link
Contributor

Overall this is looking good. If you can correct the minor things I pointed out, I think we can get this merged.

Nice job!

@keitwb
Copy link
Author

keitwb commented May 25, 2016

Thanks, I cranked the required docker-py version requirement up to 1.7+ since that is when they added the ipam support when creating a network.

@keitwb
Copy link
Author

keitwb commented May 27, 2016

@chouseknecht I realized that this module doesn't allow for any easy way to disconnect containers from an existing network without having to specify all of the containers in the network. For example, removing a container from the default bridge network after having added it to a user-defined network. I was thinking the simplest way to do this would be to have a disconnected parameter that mirrors the connected flag but for ensuring a container is disconnected. What do you think?


state:
description:
- <
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you want > here and in other spots

@chouseknecht
Copy link
Contributor

@keitwb - we reviewed this today in the community meeting, New Module Review. Here are notes on required updates before this module can be accepted.

  • There is no method for updating an existing network. If a network exists with a configuration not matching the requested configuraiton, nothing happens. However, users will get an 'ok' and think things were all good when in fact the configurations do not match. The module should compare, and if different remember which containers are connected, disconnect them, blow the network away, recreate, and then reconnect containers.
  • If connected is specified, it's canonical unless incremental is True. That's fine. However, if connected is not specified (None), the connected list should be populated with the currently connected containers so that the module does not automaticallyremove all containers from the network.

@gregdek
Copy link
Contributor

gregdek commented Jun 9, 2016

@keitwb A friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open pending your changes. When you do address the issues, please respond with ready_for_review in your comment, so that we can notify the maintainer.

[This message brought to you by your friendly Ansibull-bot.]

@keitwb
Copy link
Author

keitwb commented Jun 11, 2016

@chouseknecht I did the change for the empty/null connected param, but I'm not quite following your first point above. The module will update existing networks and should converge the network state to what is specified in the params. If you add more containers to the connected param than currently exist in the network it will add them to the existing network. Can you give a specific example of what you mean?

@gregdek
Copy link
Contributor

gregdek commented Jun 24, 2016

@keitwb Another friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open. If you have addressed the issues and believe it's ready for review, please comment with the text "ready_for_review". If we don't hear from you within another 14 days, we will close this pull request.

[This message brought to you by your friendly Ansibull-bot.]

@keitwb
Copy link
Author

keitwb commented Jun 24, 2016

ready_for_review

@gregdek
Copy link
Contributor

gregdek commented Jun 24, 2016

Thanks @keitwb for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion.

[This message brought to you by your friendly Ansibull-bot.]

@gregdek
Copy link
Contributor

gregdek commented Aug 12, 2016

Thanks @keitwb for this PR. Unfortunately, it is not mergeable in its current state due to merge conflicts. Please rebase your PR. When you are done, please comment with text 'ready_for_review' and we will put this PR back into review.

For help on how to do this cleanly please see http://docs.ansible.com/ansible/community.html#contributing-code-features-or-bugfixes

[This message brought to you by your friendly Ansibull-bot.]

@jctanner
Copy link
Contributor

replaced by #4404

@keitwb thank you for your efforts on this.

@keitwb
Copy link
Author

keitwb commented Aug 12, 2016

An updated version of this was merged in #4404 so I'm closing this.

@keitwb keitwb deleted the docker_network branch August 12, 2016 15:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants